//
//  WDButton.m
//  QMDB
//
//  Created by apple on 2019/5/25.
//  Copyright © 2019年 echo. All rights reserved.
//

#import "WDButton.h"

@implementation WDButton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
     
          [self setTitleColor:[UIColor colorWithHexString:@"2D2C2C"] forState:UIControlStateNormal];
         self.titleLabel.font = [UIFont systemFontOfSize:9];
         self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        //使图片和文字水平居中显示
        [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height ,-self
                                                  .imageView.frame.size.width, 0.0,0.0)];
        //文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变
        [self setImageEdgeInsets:UIEdgeInsetsMake(0.0, 0.0,0.0, -self.titleLabel.bounds.size.width)];//图片距离右边框距离减少图片的宽度，其它不边
  
    }
    return self;
}


-(instancetype)initWithCoder:(NSCoder *)coder{
    self = [super initWithCoder:coder];
       if (self) {
           
           [self setImageEdgeInsets:UIEdgeInsetsMake(-self.titleLabel.intrinsicContentSize.height, 0, 0, -self.titleLabel.intrinsicContentSize.width)];
           [self setTitleEdgeInsets:UIEdgeInsetsMake(self.currentImage.size.height + 10, -self.currentImage.size.width, 0, 0)];

           
           
           
//           [self setTitleColor:[UIColor colorWithHexString:@"2D2C2C"] forState:UIControlStateNormal];
//                 self.titleLabel.font = [UIFont systemFontOfSize:9];
//                 self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
//                //使图片和文字水平居中显示
//                [self setTitleEdgeInsets:UIEdgeInsetsMake(self.imageView.frame.size.height ,-self
//                                                          .imageView.frame.size.width, 0.0,0.0)];
//                //文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变
//                [self setImageEdgeInsets:UIEdgeInsetsMake(0.0, 0.0,0.0, -self.titleLabel.bounds.size.width)];//图片距离右边框距离减少图片的宽度，其它不边
       }
       return self;
    
}

@end
